import api from "@/api";
import { PORT } from "../config/servicePort";

/**
 * 获取商品列表
 */
export const getProductList = (params: any) => api.get(`${PORT}/Products/getList`, params);

/**
 * 获取商品分类列表
 */
export const getProductCategoryList = (params?: any) => api.get(`${PORT}/BaseCategory/getList`, params);

/**
 * 修改商品类别
 */
export const updateProductCategory = (params: any) => api.post(`${PORT}/BaseCategory/edit`, params);

/**
 * 获取商品状态label
 */
export const getProductStatusLabel = (params?: any) => api.get(`${PORT}/BaseProductStatus/getList`, params);

/**
 * 修改商品上下架状态
 */
export const updateProductStatus = (params: any) => api.post(`${PORT}/Products/updateProductStatus`, params);

/**
 * 删除商品
 */
export const deleteProduct = (params: any) => api.post(`${PORT}/Products/delProduct`, params);

/**
 * 商品保存
 */
export const saveProductApi = (params: any, type: "add" | "edit" | "draft") => {
	const urlInfo = {
		add: `${PORT}/Products/add`,
		edit: `${PORT}/Products/edit`,
		draft: `${PORT}/Products/saveDrafts`
	};

	return api.post(`${urlInfo[type]}`, params);
};

/**
 * 获取发货时间选项
 */
export const getDeliveryTimeList = (params?: any) => api.get(`${PORT}/BaseTimelines/getList`, params);

/**
 * 获取售后服务列表
 */
export const getAfterSaleServiceList = (params?: any) => api.get(`${PORT}/BaseAftersalesOptions/getList`, params);

/**
 * 获取商品详情接口
 */
export const getProductDetail = (params: any) => api.get(`${PORT}/Products/getInfo`, params);
